#include <iostream>
#include <vector>

using namespace std;

int countOne(int x)
{
	int cnt = 0;
	while (x > 0)
	{
		if (x % 10 == 1)
			++cnt;
		x /= 10;
	}
	return cnt;
}

int NumberOf1Between1AndN_Solution(int n)
{
	int times = 0;
	for (int i = n; i > 0; --i)
	{
		times += countOne(i);
	}
	return times;
}

//int main()
//{
//	cout << NumberOf1Between1AndN_Solution(13) << endl;
//
//	system("pause");
//	return 0;
//}
